/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package iterators;

/**
 *
 * @author Jeremy
 */

import java.util.*;
public class ReverseIterator implements Iterator<Integer> {
    
    private ArrayList<Integer> list;
    private int NextIndex;
    
    
    public ReverseIterator(ArrayList<Integer> pt) {
        list = (ArrayList<Integer>)pt.clone();
        NextIndex = list.size() - 1;
    }
    
    @Override
    public boolean hasNext() {
        if(NextIndex >= 0) return true;
        else return false;
    }

    @Override
    public Integer next() {
        return list.get(NextIndex--);
    }

    @Override
    public void remove() {
        throw new UnsupportedOperationException("Not supported yet.");
    }
    
}
